package com.nd.test.service;

import java.util.List;
import java.util.Date;

import model.po.CouponsSendingType;
import com.nd.test.vo.CouponsSendingTypeVo;
import com.nd.test.repository.CouponsSendingTypeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**   
 * Create by apisdk 
 */
@Service
public class CouponsSendingTypeService {
	@Autowired
	private CouponsSendingTypeRepository couponsSendingTypeRepository;

	/**
	* @description create model
	* @return
	*/
	public CouponsSendingTypeVo createCouponsSendingType(CouponsSendingTypeVo couponsSendingTypeVo) throws Exception {
		CouponsSendingType couponsSendingType = new CouponsSendingType();
		BeanUtils.copyProperties(couponsSendingTypeVo, couponsSendingType);
		couponsSendingType =  couponsSendingTypeRepository.save(couponsSendingType);
		BeanUtils.copyProperties(couponsSendingType, couponsSendingTypeVo);
		return couponsSendingTypeVo;
	}

	/**
	* @description get model through id
	* @return
	*/
	public List<CouponsSendingTypeVo></Vo> getCouponsSendingTypeByExample(CouponsSendingTypeVo couponsSendingTypeVo){
		CouponsSendingType couponsSendingType = new CouponsSendingType();
		BeanUtils.copyProperties(couponsSendingTypeVo, couponsSendingType);
	}

	/**
	* @description update model through id
	* @return
	*/
	public CouponsSendingTypeVo updateCouponsSendingTypeById(@PathVariable String id,@RequestBody CouponsSendingTypeVo couponsSendingTypeVo){
		//TODO to finish update code
		return couponsSendingTypeVo;
	}

	/**
	* @description delete model through id
	* @return
	*/
	public void deleteCouponsSendingTypeById(@PathVariable String id){
		CouponsSendingType couponsSendingType =  couponsSendingTypeRepository.findOne(id);
		if(couponsSendingType!=null){
			couponsSendingTypeRepository.delete(couponsSendingType);
		}
		return;
	}

}
